package cn.wuxq.saa03chatclient.controller;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RequestMapping("chatclientv1")
@RestController
public class ChatClientControllerV1 {

    @Autowired
    private ChatClient chatClient;


    @GetMapping("/chat")
    public String doChat(@RequestParam(name = "msg",defaultValue = "你是谁") String message) {
       return chatClient.prompt().user(message).call().content();
    }

    @GetMapping("/streamchat")
    public Flux<String> stream(@RequestParam(name = "msg",defaultValue = "你是谁") String message) {
        return chatClient.prompt().user(message).stream().content();
    }
}
